subroutine print_event_profile(nunit)
  use param
  use event_param
  use table_param,only:event_profile
  use table_param,only:n_event_profile
  implicit none

  integer,intent(in) :: nunit

  integer :: i,j,in1,in2,in3,pos1,pos2,width
  character(len=len_linebuf) :: str,fstr

  in1=1
  in2=2
  in3=3
  width=70

  call log_msg1(nunit,"")
  call log_msg1(nunit,"List of event profile")
  call log_msg1(nunit,"")  

  pos1=0
  pos2=pos1+23
  write(str(pos1+1:pos2),'("n_event_profile=",i7)') &
       n_event_profile
  pos1=pos2
  call log_msg1_indent(nunit,in1,str(1:pos2))

  ! Draw the header
  call drawline(nunit,in1,width)
  pos1=0

  pos2=pos1+8
  write(str(pos1+1:pos2),'("index",3x)') 
  pos1=pos2

  pos2=pos1+13
  write(str(pos1+1:pos2),'("event_type",3x)')
  pos1=pos2

  pos2=pos1+7
  write(str(pos1+1:pos2),'("n_event")')
  pos1=pos2

  pos2=pos1+7
  write(str(pos1+1:pos2),'(2x,"alloc")')
  pos1=pos2

  pos2=pos1+7
  write(str(pos1+1:pos2),'(3x,"id",2x)')
  pos1=pos2

  pos2=pos1+7
  write(str(pos1+1:pos2),'(2x,"sqnc",1x)')
  pos1=pos2

  pos2=pos1+14
  write(str(pos1+1:pos2),'(4x,"rate_const")')
  pos1=pos2

  pos2=pos1+7
  write(str(pos1+1:pos2),'(4x,"ext")')
  pos1=pos2

  call log_msg1_indent(nunit,in1,str(1:pos2))
  call drawline(nunit,in1,width)

  do i=1,n_event_profile
     pos1=0

     pos2=pos1+8
     write(str(pos1+1:pos2),'("[",i6.6,"]")') i
     pos1=pos2

     pos2=pos1+13
     select case(event_profile(i)%event_type)
     case(diff_event)
        write(str(pos1+1:pos2),'(1x,"<diff_event>")')
     case(diss_event)
        write(str(pos1+1:pos2),'(1x,"<diss_event>")')
     case(rctn_event)
        write(str(pos1+1:pos2),'(1x,"<rctn_event>")')
     case(extn_event)
        write(str(pos1+1:pos2),'(1x,"<extn_event>")')
     case(sink_event)
        write(str(pos1+1:pos2),'(1x,"<sink_event>")') 
     case(srce_event)
        write(str(pos1+1:pos2),'(1x,"<srce_event>")') 
     end select
     pos1=pos2

     pos2=pos1+7
     write(str(pos1+1:pos2),'(1x,i6)') &
          event_profile(i)%n_event
     pos1=pos2

     pos2=pos1+7
     write(str(pos1+1:pos2),'(1x,i6)') &
          event_profile(i)%n_alloc_event
     pos1=pos2

     pos2=pos1+7
     write(str(pos1+1:pos2),'(1x,i6)') &
          event_profile(i)%index
     pos1=pos2

     pos2=pos1+7
     write(str(pos1+1:pos2),'(1x,i6)') &
          event_profile(i)%sqnc
     pos1=pos2

     pos2=pos1+14
     write(str(pos1+1:pos2),'(1x,1pe13.5)') &
          event_profile(i)%rate_const
     pos1=pos2

     if (event_profile(i)%event_type.eq.extn_event) then
        pos2=pos1+7
        write(str(pos1+1:pos2),'(1x,i6)') &
             event_profile(i)%external_remain
        pos1=pos2
     else
        pos2=pos1+7
        write(str(pos1+1:pos2),'(7x)')
        pos1=pos2
     end if

     call log_msg1_indent(nunit,in1,str(1:pos2))

     do j=1,event_profile(i)%n_event
        pos1=0
        
        pos2=pos1+6
        write(str(pos1+1:pos2),'("(",i4.4,")")') j
        pos1=pos2

        pos2=pos1+8
        write(str(pos1+1:pos2),'(1x,i7)') &
             event_profile(i)%event_list(j)
        pos1=pos2

        call log_msg1_indent(nunit,in1+2,str(1:pos2))
     end do
  end do

  call drawline(nunit,in1,width)

  return

end subroutine print_event_profile
